<%--
  Created by IntelliJ IDEA.
  User: xie392
  Date: 2023/6/7
  Time: 16:10
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="com.jwxt.DatabaseQuery" %>
<%@ page import="com.jwxt.Crypto" %>
<%@ page import="java.util.List" %>

<%
    String email = request.getParameter("email");
    String password = request.getParameter("password");
    String sql = "select email,password,userName from webuser where email = '" + email + "' and password = '" + Crypto.encrypt(password) + "'";

    List<List<String>> list = DatabaseQuery.query(sql);

    if (list != null && list.size() == 0) {
        session.setAttribute("message", "用户名或密码错误");
        response.sendRedirect("../pages/login.jsp");
    } else {
        if (list != null) {
            session.setAttribute("message", "登录成功");
            session.setAttribute("userName", list.get(0).get(2));
            session.setAttribute("email", list.get(0).get(0));
        }
        response.sendRedirect("../index.jsp");
    }
%>


